/***************************************************************************
 *            gui.hpp
 *
 *  Sun May 3 17:54:13 2009
 *  Copyright  2009  Jorge Eduardo Cardona Gaviria
 *  <jorgeecardona@gmail.com>
 ****************************************************************************/

/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
 */
 
#ifndef _GUI_HPP_
#define _GUI_HPP_

#include <libglademm/xml.h>
#include <gtkmm.h>
#include <iostream>
#include <unistd.h>
#include <vector>
#include <sstream>
#include <glib/gstdio.h>

class Gui
{
public:
	Gui(Glib::RefPtr<Gnome::Glade::Xml> refXml);


	/* DataModel */
		
	class TaskColumns : public Gtk::TreeModelColumnRecord
	{
	public:
		TaskColumns(){
			add(name);
			add(elapsed);
			add(timer);
		}
		Gtk::TreeModelColumn<Glib::ustring> name;
		Gtk::TreeModelColumn<Glib::ustring> elapsed;
		Gtk::TreeModelColumn<Glib::Timer* > timer;
	};
	TaskColumns *task_columns;
	Glib::RefPtr< Gtk::TreeStore > task_store;
//	Glib::RefPtr< Gtk::TreeModelFilter > task_store_active;


	/* Widgets */
	Gtk::ToolButton *new_task_toolbutton;
	Gtk::ToolButton *start_task_toolbutton;
	Gtk::ToolButton *stop_task_toolbutton;	
	Gtk::ToolButton *stop_all_task_toolbutton;	
	Gtk::TreeView   *treeview_tasks;	
	Gtk::Window		*main_window;
	
	// Callback
	bool refresh_timers(int i);
	//static bool task_active(const Gtk::TreeModel::const_iterator& iter);
	bool refresh_timer(const Gtk::TreeModel::const_iterator& iter);
	
	
protected:

	//Signal handlers:
	virtual void on_new_task_toolbutton_clicked();
	virtual void on_start_task_toolbutton_clicked();
	virtual void on_stop_task_toolbutton_clicked();
	virtual void on_stop_all_task_toolbutton_clicked();

};

#endif /* _GUI_HPP_ */
